// createRouter: 创建路由实例对象
// createWebHistory: 创建history模式的路由
import { createRouter, createWebHistory } from 'vue-router'
import { adminRoutes } from './adminRoutes';
import { employeeRoutes } from './employeeRoutes';
import { frontRoutes } from './frontRoutes';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  //path和component对应关系的位置
  routes: [
    ...adminRoutes,
    ...employeeRoutes,
    ...frontRoutes,
  ]
})

// 添加全局后置钩子函数，来实现每次路由变化时页面滚动到顶部
router.afterEach(() => {
  window.scrollTo(0, 0);
})

export default router
